package dome1;

public class Outclass {
    private int a;
    static int b;
    int c = 30;
    public void methodA() {
        a = 10;
        System.out.println("a = " + a);
    }
    public static void methodB() {
        System.out.println("b = " + b);
    }

//实例内部类
    class innerClass {
        int c;
        public void methodInner() {
            //在实例内部类中可以直接访问外部类中：任意访问限定修饰符的成员
            a = 100;
            b = 200;
            methodA();
            methodB();
            //如果外部类和实例内部类有相同名称成员，优先访问内部类自己的
            c = 300;
            System.out.println("c = " + c);
            //若要访问外部类的同名成员时，必须：外部类名称.this.同名成员名名字
            System.out.println("c = " + Outclass.this.c);
        }
    }

    public static void main(String[] args) {
        //外部类：对象的创建以及成员访问
        Outclass outClass = new Outclass();
        System.out.println(outClass.a);
        System.out.println(outClass.b);
        System.out.println(outClass.c);
        outClass.methodA();;
        outClass.methodB();;
        System.out.println("*************实例内部类访问*************");
        //创建内部类对象
        Outclass.innerClass innerClass1 = outClass.new innerClass();
        innerClass1.methodInner();
        System.out.println();
        Outclass.innerClass innerclass2 = new Outclass().new innerClass();
        innerclass2.methodInner();
    }
}
